<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!--引用CW标签  -->
<%@ taglib uri="/WEB-INF/taglib/cw" prefix="CW"%>
<!--引用struts标签  -->
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<base href="<%=basePath%>">
	<title></title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="<%=basePath%>css/en/edit.css" rel="stylesheet" type="text/css">
	<link href="<%=basePath%>css/en/list.css" rel="stylesheet"type="text/css">
	<script type="text/javascript" src="<%=basePath%>js/commons/common_edit.js"></script>
</head>
<body>
	<jsp:include page="../../../common/loadingPage.jsp" />
	<form action="user/addUser.action" name="addUserForm" id="addUserForm" method="post">
		<!-- 页面头 -->
		<input name="fileFileName" id="fileFileName" type="hidden" />
		<div class="pageheader">
			<!-- 页面标题 -->
			<div class="pagetitle">
				新增用户
			</div>
			<!-- 操作按钮 -->
			<div class="pageheadercontent">
				<div class="toolbar">
					<div class="toolbarright">
						<input class="okbtn" name="_submit" type="button" value="OK" onclick="__submit()"> 
						<input class="calbtn" name="_back" type="button" value="Cancel" onclick="__back()">
					</div>
				</div>
			</div>
		</div>
		<!-- 编辑 -->
		<div class="writetblbox" style="width:750px">
			<table class="writetbl" style="width: 100%">
				<tr>
					<th style="width: 25%">账号：</th>
					<td><input name="userInfo.UserName" type="text" id="userInfo.UserName" ></td>
				</tr>
				<tr>
					<th>用户全名：</th>
					<td><input name="userInfo.FullName" type="text" ></td>
				</tr>
				<tr>
					<th>性别：</th>
					<td><select name="userInfo.Sex" id="Sex"> 
							<option value="0">--请选择--</option>
							<option value="1">男</option>
							<option value="2">女</option>
						</select>
					</td>
				</tr>
				<tr>
					<th>邮箱：</th>
					<td><input type="text" name="userInfo.EmailAddress" ></td>
				</tr>
			</table>
		</div>
	</form>
	<span class="_height"></span>
	<script type="text/javascript">
		/*!
		* 
		* 绑定验证
		* 
		* 注意1：所有的验证规则统一在此处进行定义
		* 注意2：当input中name使用pentity.name这样的命名方式时,其中"."与JQUERY冲突, 则rules: {"pentity.name": {}} 要加上双引号 
		* 
		*/
		$(document).ready(function() {
			$('#addUserForm').validate({
				rules : {
			        "userInfo.FullName" : {
						required : true,
						maxlength : 32
					},
				    "userInfo.EmailAddress" : {
						email : true,
						rangelength:[3,32]
					},
					"userInfo.UserName" : {
						number : true,
						rangelength:[3,16]
					}
				}
			});
		});
		function _validateUser(){
			var result=true;
			$.ajax({  
			    type: "post",  
			    async: false,
			    url: "<%=basePath%>/userValidate/validateUser.action",  
				    data: "UserName=" + $("#userInfo.UserName").val() ,  
				    success: function(data){ 
				    	var isReapeat = data[0].isReapeat;
				    	if(isReapeat=='1'){//重复
						    art.dialog.alert('该用户名已经存在，请重新输入');
						    result=false;
				    	}
				    }
			});
			return result;
		}
		function __submit(){
			if($("#addUserForm").valid()&&_validateUser()){
				$("#loadingdiv").show();
				document.addUserForm.action="<%=basePath%>user/addUser.action";
				document.addUserForm.submit();
			} 
		}
		function __back(){
			document.addUserForm.action="<%=basePath%>/user/getAllUser.action";
			document.addUserForm.submit();
		}
	</script>
</body>
</html>
